<?php
// Author: dolphinigle
// 28 March 2012

function InitLikeDislike() {
  echo '<script type="text/javascript" src="like_dislike_system.js"></script>';
}

function AddLikeDislike($id) {
  if (isSet($_SESSION['username'])) {
    $user = $_SESSION['username'];
    echo '<button id="like_button', $id, '" onclick="LikeClicked(\'', $id, '\', \'', $user, '\')">Like</button>';
    echo '<button id="dislike_button', $id, '" onclick="DislikeClicked(\'', $id, '\', \'', $user, '\')">Dislike</button>';
  } else {
    $user = "";
    echo 'You have to log in to Like/Dislike';
  }
  
  echo '<span id="like_count', $id, '"></span>/<span id="dislike_count', $id, '"></span>';
  echo '<script type="text/javascript">PutLikes(', $id, ', "', $user, '");' .
       'PutDislikes(', $id, ', "', $user, '");</script>';
}
?>
